package com.xbongbong.paas.model;

import com.xbongbong.paas.domain.entity.PaasUserEntity;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author: 汪腾伟
 * @date: Created in 2022/1/10 9:33
 * @description： 团队成员用户model层
 */
public interface PaasUserModel {

    /**
     * 查询paas表单团队信息
     *
     * @param map
     * @return
     */
    List<UserTeamEntity> findBaseEntitys(Map<String, Object> map);

    /**
     * 批量插入paas团队用户信息
     *
     * @param paasUserEntities
     */
    void insertBatch(List<PaasUserEntity> paasUserEntities) throws XbbException;

    void insertBatch(List<PaasUserEntity> paasUserEntities, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * 查询paas表单团队信息
     *
     * @param map
     * @return
     */
    List<PaasUserEntity> findEntitys(Map<String, Object> map);

    /**
     * 更新paas表单团队信息
     *
     * @param paasUserUpdateEntities
     */
    void updateBatch(List<PaasUserEntity> paasUserUpdateEntities);

    /**
     * 批量更新paas团队信息
     *
     * @param corpid 公司id
     * @param idIn 主数据id
     * @param delUserTeamList 需要删除的团队
     * @param isMain 是否是主负责人标识 1：负责人 0：协同人
     * @param del 删除标识
     */
    void batchUpdateByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> delUserTeamList, Integer isMain, Integer del) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> delUserTeamList, Integer isMain, Integer del, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * 只往数据库插入，但是不插入es
     *
     * @param paasUserInsertEntities
     */
    void insertNoEsBatch(List<PaasUserEntity> paasUserInsertEntities);

    Integer getEntitysCount(Map<String, Object> param);

    /**
     * 获取paas团队信息
     *
     * @param id
     * @param corpid
     * @return
     */
    PaasUserEntity getByKey(Long id, String corpid);

    /**
     * 编辑协同人表单权限
     *
     * @param shouldUpdateEntity
     */
    void updateEditFormPer(PaasUserEntity shouldUpdateEntity) throws XbbException;

    /**
     * paas表单编辑标签
     *
     * @param paasUserEntity
     */
    void editLabel(PaasUserEntity paasUserEntity) throws XbbException;

    /**
     * 更新团队协同人信息和协同人可编辑权限
     *
     * @param corpid
     * @param idIn
     * @param updateUserToCoTeamList
     * @param coopUser
     * @param needThrow
     */
    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> updateUserToCoTeamList, Integer coopUser, boolean needThrow) throws XbbException;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    List<PaasUserEntity> getPaasUserList(String corpid, Long dataId, Integer isMain);

    void deleteBatch(String corpid, List<PaasUserEntity> paasUserList, Integer del) throws XbbException;
}
